import React from 'react';

import BaseAction from '../common/BaseAction';
import Constants from '../../common/Constants';
import ResponseConstants from '../../common/ResponseConstants';

export default class HeartVolunteerSubmitAction extends BaseAction{
  constructor() {
    super();

    this.moduleType = Constants.MODULE_TYPE.HEART;
    this.name = "HeartVolunteerSubmitAction";
  }

  call(caller, data) {
    this._baseCall(caller, data);
    this.caller.setState({
      viewStatus: 2,
    })
  }

  finish(data, isSucceed, response) {
    let detailText = "";
    if(isSucceed) {
      viewStatus = 3;
      detailText = "您的申请我们已收到，经过筛选，成功进入志愿者资料库的，我们会在组织相关志愿服务时通过您的手机与您取得联系";
    }
    else {
      viewStatus = 4;
      if(data && data.detail) {
        detailText = data.detail;
      }
      else if(response.status == ResponseConstants.status_conflict) {
        detailText = "您已经提交过申请了";
      }
      else {
        detailText = "申请失败";
      }
    }
    this.caller.setState({
      viewStatus: viewStatus,
      detailText: detailText,
    })
  }
}
